import Cookies from 'js-cookie';

const TokenKey = process.env.TOKEN_KEY;
const domain = process.env.COOKIE_DOMAIN;

export function getToken() {
  if (process.env.TARGET_ACTION === 'dev') {
    return Cookies.get(TokenKey);
  }
  return Cookies.get(TokenKey, { domain: domain });
}

export function setToken(token) {
  if (process.env.TARGET_ACTION === 'dev') {
    return Cookies.set(TokenKey, token);
  }
  return Cookies.set(TokenKey, token, { domain: domain });
}

export function removeToken() {
  Cookies.remove(TokenKey);
  Cookies.remove(TokenKey, { domain: 'tnaot.cn' });
  return Cookies.remove(TokenKey, { domain: domain });
}
